<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./script/jquery.js"></script>
</head>
<body>
    <input type="text">
    <button>添加</button>
    <ul class="fruit-list">
        <li>邓伦</li>
        <li>爱你</li>
        <li>啊</li>
    </ul>

    <script>
        // remove() 删除  点击哪个li就删除哪个li
        // $(".fruit-list li").click(function(){
        //     $(this).remove()
        // })

        // append添加东西
        $('button').click(function(){
            let value = $("input").val()
            let li = $(`<li>${value}</li>`)
            $(".fruit-list").append(li)
        })

        // on("处理类型","处理元素",函数)事件委托，将子级的时间委托给父级处理
        $(".fruit-list").on("click","li",function(){
            $(this).remove()
        })
    </script>
</body>
</html>